
//欧拉筛法
#include <bits/stdc++.h>
using namespace std;
struct  ST {
    string name;
    double ch,ma,en,sum;
    int id;
};

ST boys[100000];
bool cmp(ST A,ST B) {
   return A.sum >B.sum || (A.sum==B.sum && A.id<B.id);
}
int main() {
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>> boys[i].name>>boys[i].ch>>boys[i].ma>>boys[i].en;
        boys[i].id=i;
        boys[i].sum=boys[i].ch+boys[i].en+boys[i].ma;
    }

    sort(boys+1,boys+n,cmp);


    return 0;
}
